{{ define "index" }}

<!DOCTYPE html>
<html lang="en">

<head>

  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">

  <title>GoFlow - Dashboard</title>

  <!-- Custom fonts for this template-->
  <link href="/static/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
  <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">

  <!-- Custom styles for this template-->
  <link href="/static/css/sb-admin-2.min.css" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet">


  <!-- Bootstrap core JavaScript-->
  <script src="/static/vendor/jquery/jquery.min.js"></script>
  <script src="/static/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
  <script src="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/js/bootstrap4-toggle.min.js"></script>

  <!-- Core plugin JavaScript-->
  <script src="/static/vendor/jquery-easing/jquery.easing.min.js"></script>

  <!-- PublicURL override -->
  <script>
    let serverAddr={{ .PublicURL }};
  </script>

  <!-- graphviz library dependency -->
  <script src="//d3js.org/d3.v4.min.js"></script>
  <script src="https://unpkg.com/viz.js@1.8.0/viz.js" type="javascript/worker"></script>

  <!-- graphviz library -->
  <script src="https://unpkg.com/d3-graphviz@1.4.0/build/d3-graphviz.min.js"></script>

  <!-- main script -->
  <script type="text/javascript" src="/static/js/main.js"></script>

</head>

<body id="page-top">

  <!-- Page Wrapper -->
  <div id="wrapper">

    <!-- Sidebar -->
    <ul class="navbar-nav bg-gradient-dark sidebar sidebar-dark accordion" id="accordionSidebar">

      <!-- Sidebar - Brand -->
      <a class="sidebar-brand d-flex align-items-center justify-content-center" href="https://github.com/s8sg/goflow">
        <div class="sidebar-brand-icon">
	  <i class="fas fa-draw-polygon"></i>
        </div>
        <div class="sidebar-brand-text mx-3">goflow <sup>dashboard</sup></div>
      </a>

      <!-- Divider -->
      <hr class="sidebar-divider my-0">

      <!-- Nav Item - Dashboard -->
      <li class="nav-item">
        <a class="nav-link" href="/">
          <i class="fas fa-fw fa-tachometer-alt"></i>
          <span>Dashboard</span></a>
      </li>


      <!-- Divider -->
      <hr class="sidebar-divider">

      <!-- Heading -->
      <div class="sidebar-heading">
        Requests
      </div>

      <li class="nav-item">
	<a class="nav-link collapsed" href="/flow/requests">
          <i class="fas fa-fw fa-forward"></i>
          <span>Active Requests</span>
        </a>
      </li>

      <li class="nav-item">
	<a class="nav-link collapsed" href="/flow/requests">
	  <i class="fas fa-fw fa-history"></i>
          <span>History</span>
        </a>
      </li>


      <!-- Divider -->
      <hr class="sidebar-divider">

      <!-- Heading -->
      <div class="sidebar-heading">
        Flows
      </div>

      <!-- Nav Item - Pages Collapse Menu -->
      {{ range .Functions }}
      <li class="nav-item">
	      <a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#{{.Name}}" aria-expanded="true" aria-controls="collapseTwo">
          <!-- <i class="fas fa-fw fa-sitemap"></i> -->
          <span>{{.Name}}</span>
        </a>
	    <div id="{{.Name}}" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionSidebar">
          <div class="bg-white py-2 collapse-inner rounded">
            <h6 class="collapse-header">Manage</h6>
            <a class="collapse-item" data-toggle="tooltip" title="Click to see {{.Name}} details" href="/flow/info?flow-name={{ .Name }}">
		      <i class="fas fa-fw fa-cogs"></i>
		      <span>Details</span>
	        </a>
	        <h6 class="collapse-header">Requests</h6>
            <a class="collapse-item" data-toggle="tooltip" title="Click to find all requests of {{.Name}} " href="/flow/requests?flow-name={{ .Name }}">
		      <i class="fas fa-fw fa-tasks"></i>
		      <span>List</span>
	        </a>
            <a class="collapse-item" data-toggle="tooltip" title="Click to monitor requests of {{.Name}} " href="/flow/request/monitor?flow-name={{ .Name }}">
		      <i class="fas fa-fw fa-search-plus"></i>
              <span>Monitor</span>
            </a>
          </div>
        </div>
      </li>
      {{ end }}
      
      <!-- Divider -->
      <hr class="sidebar-divider">

      <!-- Sidebar Toggler (Sidebar) -->
      <div class="text-center d-none d-md-inline">
        <button class="rounded-circle border-0" id="sidebarToggle"></button>
      </div>

    </ul>
    <!-- End of Sidebar -->

    <!-- Content Wrapper -->
    <div id="content-wrapper" class="d-flex flex-column">

      <!-- Main Content -->
      <div id="content">

        <div id="alert.container"/></div>

        <!-- Topbar -->
        <nav class="navbar navbar-expand navbar-light bg-white mb-4 static-top shadow">

          <!-- Sidebar Toggle (Topbar) -->
          <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
            <i class="fa fa-bars"></i>
          </button>


          <!-- Topbar Navbar -->
          <div class="collapse navbar-collapse" id="navbarNavDropdown">
          <ul class="navbar-nav mr-auto mt-2 mt-lg-0">

            {{ if .LocationDepths }}
              {{ range .LocationDepths }}

                <li class="nav-item">
		          <a class="nav-link text-capitalize" href="{{ .Link }}">
                    <i class="fa fa-angle-right"> </i>
                    {{ .Name }}
                  </a>
                </li>
              {{ end }}
	        {{ end }}
            
	        {{ if .CurrentLocation }}

	          {{ if eq .CurrentLocation.Name "requests-choice" }}
                <li class="nav-item dropdown active">
                  {{ if not .Requests.TracingEnabled }}
                  <a class="btn btn-secondary dropdown-toggle text-uppercase disabled" href="#" id="navbardrop" data-toggle="dropdown">
                    <i class="fa fa-angle-right"></i>
                    <span id="selected-request">
                    </span>
                  </a>
                  {{ end }}
	              {{ if .Requests.TracingEnabled }}
                    {{ $flowName := .Requests.Flow }}
                    <a class="btn btn-secondary dropdown-toggle" href="#" id="navbardrop" data-toggle="dropdown">
                      <i class="fa fa-angle-right"></i>
                      <span id="selected-request">
                      {{ .Requests.CurrentRequestID }}
                    </span>
                    </a>
                    <div class="dropdown-menu">
                    {{ range $key, $value :=  .Requests.Requests }}
                      <a class="dropdown-item" id="{{ $key }}" href="/flow/request/monitor?flow-name={{ $flowName }}&request={{ $key }}">{{ $key }}</a>
		            {{ end }}
                    </div>
	              {{ end }}
                </li>
              {{ end }}

              {{ if ne .CurrentLocation.Name "requests-choice" }}
              <li class="nav-item">
                <a class="nav-link active text-capitalize" href="{{ .CurrentLocation.Link }}">
                  <i class="fa fa-angle-right"></i>
                  {{ .CurrentLocation.Name }}
                </a>
              </li>
              {{ end }}

	        {{ end }}
	        <!-- Other topbar item goes here -->
          </ul>
          </div>


          <div class="topbar-divider d-none d-sm-block"></div>
          <!-- END Topbar Navbar-->

        </nav>
        <!-- End of Topbar -->

        <!-- Begin Page Content -->
        <div class="container-fluid">
    
        {{ if eq .InnerHtml "dashboard" }}
          {{ template "dashboard" .}}
        {{ end }}

        {{ if eq .InnerHtml "flow-info" }}
          {{ template "flow-info" .}}
        {{ end }}

        {{ if eq .InnerHtml "requests" }}
          {{ template "requests" .}}
        {{ end }}

        {{ if eq .InnerHtml "request-monitor" }}
            {{ template "request-monitor" .}}
        {{ end }}

        </div>
        <!-- /.container-fluid -->

      </div>
      <!-- End of Main Content -->

      <!-- Footer -->
      <footer class="sticky-footer bg-white">
        <div class="container my-auto">
          <div class="copyright text-center my-auto">
            <span>Created with love by s8sg and friends</span>
          </div>
        </div>
      </footer>
      <!-- End of Footer -->

    </div>
    <!-- End of Content Wrapper -->

  </div>
  <!-- End of Page Wrapper -->

  <!-- Scroll to Top Button-->
  <a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
  </a>

  <!-- Custom scripts for all pages-->
  <script src="/static/js/sb-admin-2.min.js"></script>

</body>

</html>

{{ end }}
